using System;
using System.Collections.Generic;
using System.Drawing;
using NetTopologySuite.Features;
using NetTopologySuite.Geometries;
using SkiaSharp;
using ZMap.Layer;
using ZMap.Renderer;
using ZMap.Style;

namespace ZMap
{
    public class Map : IMap
    {
        public double MinVisible { get; set; }
        public double MaxVisible { get; set; }
        public VisibilityUnits VisibilityUnits { get; set; }

        public void Dispose()
        {
            using var canvas = new SKCanvas(new SKBitmap(100, 100));
            canvas.DrawLine(0, 0, 0, 0, new SKPaint());

            using var graphics = Graphics.FromImage(new Bitmap(100, 100));
            graphics.DrawLine(new Pen(Color.Aqua), 0, 0, 0, 0);
        }


        public Guid Id { get; set; }
        public object Target { get; set; }

        /// <summary>
        /// The map's view.  No layer sources will be
        /// fetched unless this is specified at construction time or through
        /// </summary>
        public IView View { get; set; }

        public IViewport Viewport { get; set; }
        public GeometryFactory GeometryFactory { get; set; }
        public Envelope Envelope { get; set; }
        public Envelope EnvelopeOfLayers { get; set; }
        public IReadOnlyCollection<ILayer> Layers { get; set; }
        public int MaxTilesLoading { get; set; } = 16;
        public int PixelRatio { get; set; }
        public int MoveTolerance { get; set; }
 
        public Map()

        {
            CreateOptions();

            // Register events

            // 

            // Call render()

            // create transform

            //
        }

        private void CreateOptions()
        {
        }

        public void AddLayer(ILayer layer)
        {
            throw new NotImplementedException();
        }

        public string BackgroundColor { get; set; }
        public int Width { get; set; }
        public int Height { get; set; }

        public double Scale { get; }

        public Feature GetFeaturesAtPixel(Coordinate pixel, int hitTolerance, Func<ILayer, bool> layerFilter)
        {
            throw new NotImplementedException();
        }

        public Coordinate GetCoordinateFromPixel(Coordinate pixel)
        {
            throw new NotImplementedException();
        }

        public IMapRenderer Renderer { get; private set; }

        public void Render()
        {
            if (Renderer == null)
            {
                Renderer = new MapRenderer();
            }

            Renderer.Render();
        }
    }
}